package net.area80.utils
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	
	public class Cleaner
	{
		public static function disposeOnRemoved (o:DisplayObject):void	{
			if(o["dispose"] != null) {
				o.addEventListener(Event.REMOVED_FROM_STAGE,doDispose,false,0,true);
			}
		}
		private static function doDispose (e:Event = null):void {
			if(e.currentTarget["dispose"] != null) {
				e.currentTarget["dispose"]();
			}
		}

	}
}